package com.example.homeworkrabbitmq.service.impl;

import com.example.homeworkrabbitmq.entity.Course;
import com.example.homeworkrabbitmq.repository.CourseRepository;
import com.example.homeworkrabbitmq.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {
    @Autowired
    private CourseRepository courseRepository;

    @Override
    @Transactional
    public void saveList(List<Course> list){
        List<Course> courses = courseRepository.saveAll(list);
    }

    @Override
    public List<Course> list(){
        return courseRepository.findAll();
    }

    @Override
    public Course findById(Integer courseId){
       return courseRepository.findById(courseId).orElse(null);
    }



}
